<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 200px;
            height: 200px;
            border: 1px solid green;
        }
        .container{
            color: red;
        }
    </style>
</head>
<body>
    <!-- <div class="box active" id="gaga" wtf="nmsl">????</div> -->
    <script>
        var getbox = document.querySelector(".box")
        // console.log( getbox.className)
        // document.onclick = function (){
        //     getbox.className += " container"
        // }
        // var res = getbox.getAttribute("class")获取属性
        // console.log(res)
        document.onclick = function(){
           var res =  getbox.attributes//获取所有属性
            getbox.setAttribute("www","wwwweeee")//添加属性
            getbox.removeAttribute("class")//删除属性
        }
    </script>
</body>
</html>